import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import EffectCommon from 'code/Core/Common/EffectCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/* 愈合 */
export default class DLY_Recovers extends AbilityBase {
    static instance: DLY_Recovers;
    buffType: AppBuffType = {
        id: 'buff_DLY_Recovers',
        art: this.art,
        name: this.abilityName,
        ubertip: '受到持续治疗，并提高受到治疗的效果',
        stackCountMax: -1,
        attribute: {
            受到治疗增强: 0.05,
        },
        interval: 2,
        dur: 12,
        onInterval: this.buffInterval.bind(this),
        targetArt: 'Abilities\\Spells\\NightElf\\Barkskin\\BarkSkinTarget.mdl',
        targetAttach: 'overhead',
    };
    constructor(id: string) {
        super(id);
        DLY_Recovers.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let lv = this.getAbilityLevel(source);
        // BuffUtil.addBuff(target, this.buffType.id, source);
        BuffCommon.addBuff({
            target: target,
            buffTypeId: this.buffType.id,
            caster: source,
            ablityId: this.id,
        });
        let dmg = 20 * lv + UnitCommon.取法强(source) * (0.8 + 0.4 * lv);
        DamageSystemInstance.applyHeal(target, source, dmg, this.id);
        EffectCommon.addEffectAndDeleyRemove('Objects\\Spawnmodels\\NightElf\\EntBirthTarget\\EntBirthTarget.mdl', tarX, tarY, 2);
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
    buffInterval(buff: Buff) {
        let source = buff.getParent();
        let lv = this.getAbilityLevel(source);
        let dmg = 10 * lv + UnitCommon.取法强(source) * (0.3 + 0.1 * lv);
        DamageSystemInstance.applyDotHeal(buff.getParent(), source, dmg, this.id);
    }
}
